package threadPool1;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MyThreadPoolDemo {
    public static void main(String[] args) throws InterruptedException {
        /*
        * public static ExecutorService newCachedThreadPool() 创建一个没有上线的线程池
        * public static ExceutorService newFixedTreadPool(int nThread) 创建一个有上限的线程池
        * */

        //1.获取线程池对象
        ExecutorService pool1 = Executors.newFixedThreadPool(3);

        //2.提交任务 可以提交Runnable和Callable的实现类
        Runnable r = new MyRunnable();
        pool1.submit(r);
        pool1.submit(r);
        pool1.submit(r);
        pool1.submit(r);
        pool1.submit(r);
        //3.销毁线程池
        //pool1.shutdown();
    }
}
